package vn.com.pavibook.admin.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import vn.com.pavibook.dao.BookTypeDao;
import vn.com.pavibook.domain.model.BookType;
import vn.com.pavibook.domain.model.PagingInfo;
import vn.com.pavibook.domain.model.SearchResult;
import vn.com.pavibook.model.vo.BookTypeVO;

@Service
public class ManageBookTypeService {
	@Autowired
	BookTypeDao bookTypeDao;
	
	public SearchResult<BookType> getBookType(String keyword, PagingInfo pagingInfo){
		return bookTypeDao.getBooks(pagingInfo, keyword);
	}
	
	public void deleteBookType( int booktypeId){
		bookTypeDao.deleteBooktype(booktypeId);
	}
	
	public boolean isExistedBooktype(String name){
		return bookTypeDao.isExistedBooktype(name);
	}
	
	public void addNewBookType(BookTypeVO bookTypeVO){
		bookTypeDao.addNewBookType(bookTypeVO);
	}
	
	public void editBookType(BookTypeVO bookTypeVO){
		bookTypeDao.editBookType(bookTypeVO);
	}
	
	public BookTypeVO getBookTypeById(int bookTypeId){
		BookType bookType = bookTypeDao.getBookTypeById(bookTypeId);
		BookTypeVO bookTypeVO = new BookTypeVO(bookType.getId(), bookType.getName(), bookType.isActive());
		return bookTypeVO;
	}
}
